﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using SGLib;
using SGLisp;

public class EffectManager :Singleton<EffectManager>
{
    Hashtable mEffectTable;
    Context mContext;
    public void Load()
    {
        mContext = new Context(RT.MainContext);
        this.defineLispFunc();
        mEffectTable = (Hashtable)SGLisp.Helper.EvalValueFromFile(Game.TABLE_PATH+"Effect.clj",mContext);
    }

    void defineLispFunc()
    {
        mContext.Define("define-effects",new FunctionNode(_define_effects));
    }

    public Effect CreateEffect(string name)
    {
        return null;//CreateEffectByLisp((ListNode)mEffectTable[name]);
    }

    public Effect CreateEffectByLisp(ListNode lstNode)
    {
        return null;
    }

    ASTNode _define_effects(List<ASTNode> args,Context context)
    {
        Hashtable hashDic = new Hashtable();
        for (int i=0;i<args.Count;i+=2)
        {
            string effectName = ((StringNode)args[i]).Val;
            ListNode lstNode = (ListNode)args[i+1];
            hashDic.Add(effectName,effectName);
        }
        return new ObjectNode(hashDic);
    }
}

/*
         GameScene
            Unit
              Abiltiy
                 Effect
              Mover
              Behavior


            SC_CreateUnit
            SC_UnitAddMover
            SC_AddBehavior
*/